/**
 * Created by xukj on 2018/6/6.
 */
import React from 'react';
import PropTypes from 'prop-types';
import { View, Image, TouchableOpacity, StyleSheet } from 'react-native';

const propTypes = {
  onPress: PropTypes.func,
  disabled: PropTypes.bool,
  style: View.propTypes.style,
  containerStyle: View.propTypes.style,
  source: PropTypes.object,
  activeOpacity: PropTypes.number
};

const ImageButton = ({
                      onPress,
                      disabled,
                      style,
                      containerStyle,
                      source,
                      activeOpacity
                    }) => (
  <TouchableOpacity
    style={containerStyle}
    onPress={onPress}
    disabled={disabled}
    activeOpacity={activeOpacity}
  >
    <Image style={[styles.image, style]} source={source} />
  </TouchableOpacity>
);

ImageButton.propTypes = propTypes;

ImageButton.defaultProps = {
  onPress() {},
  disabled: false,
  activeOpacity: 0.8
};

const styles = StyleSheet.create({
  image: {
    flex: 1,
  },
});

export default ImageButton;